package com.example.smartcity.ui.SmartCommynity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.GridView;

import com.example.smartcity.R;
import com.example.smartcity.ui.Adapter.RecommendShopAdapter;
import com.example.smartcity.ui.Adapter.ShopMessageAdapter;
import com.example.smartcity.ui.Bean.ShopMessageBean;
import com.example.smartcity.ui.Bean.recommendBean;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;

import java.util.ArrayList;

public class CommercialPromotion extends AppCompatActivity {

    ArrayList<Integer> list = new ArrayList<>();
    private Banner shopBanner;
    private RecyclerView RV_shopMessage;
    private GridView GD_recommendShop;
    ArrayList<ShopMessageBean> ShopList = new ArrayList<>();
    private static String titles[] = new String[]{
            "物业服务",
            "快件管理",
            "友邻社交",
            "商业推广",
            "车辆管理"
    };
    private static int[] hotel = new int[]{
            R.drawable.hotel_1,
            R.drawable.hotel_2,
            R.drawable.hotel_3,
            R.drawable.hotel_4,
            R.drawable.hotel_5,
            R.drawable.hotel_6,
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_commercial_promotion);
        RV_shopMessage = findViewById(R.id.shopMessage);
        shopBanner = findViewById(R.id.shopBanner);
        GD_recommendShop = findViewById(R.id.GD_RecommendedShop);
        setShopBanner();
        setRV_shopMessage();
        setGD_recommendShop();
    }
    public void setBack(View view){
        this.finish();
    }
    //商业推广
    public void setShopBanner(){
        list.add(R.drawable.shop_00);
        list.add(R.drawable.shop_01);
        list.add(R.drawable.shop_02);
        list.add(R.drawable.shop_03);
        list.add(R.drawable.shop_04);
        list.add(R.drawable.shop_05);
        shopBanner.setAdapter(new BannerImageAdapter<Integer>(list) {
            @Override
            public void onBindView(BannerImageHolder bannerImageHolder, Integer integer, int i, int i1) {
                bannerImageHolder.imageView.setImageResource(integer);
            }
        }).setBannerGalleryMZ(20).start().setIndicator(new CircleIndicator(this));
    }

    //横向的RecycleView
    public void setRV_shopMessage(){
        ShopMessageBean b1 = new ShopMessageBean("#F06292","新货到店","满99减50");
        ShopMessageBean b2 = new ShopMessageBean("#DFCD8F","酒水大促","满99减50");
        ShopMessageBean b3 = new ShopMessageBean("#4DD0E2","美食速递","送货上门");
        ShopMessageBean b4 = new ShopMessageBean("#B968C7","一家包邮","购买方便");
        ShopList.add(b1);
        ShopList.add(b2);
        ShopList.add(b3);
        ShopList.add(b4);
        ShopMessageAdapter adapter = new ShopMessageAdapter(R.layout.shopmessageitem,ShopList);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        RV_shopMessage.setLayoutManager(manager);
        RV_shopMessage.setAdapter(adapter);
    }

    public void setGD_recommendShop(){
        ArrayList<recommendBean> list = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            list.add(new recommendBean(hotel[i],"红浪漫酒店","已售99间","￥199元"));
        }
        GD_recommendShop.setAdapter(new RecommendShopAdapter(R.layout.recommandshopitemlayout,list));
    }
}